import redis
import pprint
from common.db import  query_db
import json
import string

# r = redis.Redis(host='redis-cn02kpkh5v1jicblx.redis.volces.com', port=6379, db=0,password='Yequniubi666')
#
# r.get('liveshowcenter:billboard:COMMON:zset:ACTIVITY:5337')
#
#
# print(r.get('liveshowcenter:billboard:COMMON:zset:ACTIVITY:5337'))

pool = redis.ConnectionPool(host="redis-cn02kpkh5v1jicblx.redis.volces.com",port=6379,db=0,password="Yequniubi666",decode_responses=True)
re = redis.Redis(connection_pool=pool)
j=0
for i in range(0,30):
    a=re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:174",j,i,desc=True)
    j=i+1
    b = ''.join(i for i in a if i not in string.punctuation)
    d = query_db(sql=('SELECT mobile,id FROM uaa.jhi_user WHERE id =%s'%b))
    print(b,d)
    #print(str(c))
print('派对之星')
print('主播榜',re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:174",0,0,desc=True,withscores=True))
# print('金主榜',re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:229",0,58,desc=True,withscores=True))
#
# print('元旦活动')
# print('主播榜',re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:307",0,58,desc=True,withscores=True))
# print('金主榜',re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:247",0,58,desc=True,withscores=True))
# def Readredis(number,s,e,):
#     redis1 = re.zrange(f"liveshowcenter:billboard:COMMON:zset:ACTIVITY:{number}",s,e,desc=True,withscores=True,score_cast_func=list)
#     return redis1
#
# if __name__ == '__main__':
#     Readredis(5343,0,58)
# print("复活赛",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5343",0,58,desc=True,withscores=True))

# print(type(re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5337",0,58,desc=True,score_cast_func=dict)))
# A = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5338",0,58,desc=True,withscores=True)
# B = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5339",0,58,desc=True,withscores=True)
# C = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5340",0,58,desc=True,withscores=True)
# D = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5341",0,58,desc=True,withscores=True)
# E = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5342",0,58,desc=True,withscores=True)
# # fh = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5343",0,58,desc=True)[0:3]
# # cc = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5344",0,58,desc=True)
# # df = re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5350",0,58,desc=True)
# print("a:",A)
# print("b:",B)
# print("c:",C)
# print("d:",D)
# print("e:",E)

# F = A + B + C + D + E + fh
# print(F)
# print(cc)
# set(F).symmetric_difference(set(cc))
# set(cc).symmetric_difference(set(F))




# # print(A)
# print("A组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5338",0,58,desc=True))
# print("B组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5339",0,58,desc=True))
# print("C组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5340",0,58,desc=True))
# print("D组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5341",0,58,desc=True))
# print("E组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5342",0,58,desc=True))
# # print("复活赛",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5343",0,58,desc=True)[0:3])
# # # print("金主榜",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5250",0,58,desc=True))
# # print("冲刺赛",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5344",0,58,desc=True,))
# # print(type(re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5342",0,58,desc=True,withscores=True)))
# # pprint.pprint(re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5250",0,58))
# # print(type(re.zcard("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5250")))
# print("----------------------------------------------------------------------------------------------")
# # print("A组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5338",0,58,desc=True,withscores=True)[0:3])
# # print("B组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5339",0,58,desc=True,withscores=True)[0:3])
# # print("C组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5340",0,58,desc=True,withscores=True)[0:3])
# # print("D组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5341",0,58,desc=True,withscores=True)[0:3])
# # print("E组",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5342",0,58,desc=True,withscores=True)[0:3])
# pprint.pprint(("复活赛",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5343",0,58,desc=True,withscores=True)[0:1]))
# pprint.pprint(("金主榜",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5250",0,58,desc=True,withscores=True)[0:1]))

# print("冲刺赛",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5344",0,58,desc=True,withscores=True))
# pprint.pprint(("入围赛",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5337",0,58,desc=True)[0:30]))
# pprint.pprint(("金主榜",re.zrange("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5250",0,58,desc=True,withscores=True)))
# print("冲刺奖池",re.get("liveshow:award:pool:ANNUAL_2021_SPRINT_AMOUNT"))


# # #删除金主榜
# re.delete("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5250")
# #删除入围赛
# re.delete("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5337")
# #删除冲刺奖池
# re.delete("liveshow:award:pool:ANNUAL_2021_SPRINT_AMOUNT")
# #删除用户贡献榜
# re.delete("liveshowcenter:billboard:COMMON:zset:ACTIVITY:5415")